import {defineConfig} from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'

const postcssPlugins = [tailwindcss(), autoprefixer()]

import {UnifiedViteWeappTailwindcssPlugin as uvwt} from 'weapp-tailwindcss/vite';

// https://vitejsdev/config/
export default defineConfig({
    plugins: [
        uni(),
        uvwt({
            rem2rpx: true
        })],
    server: {
        proxy: {
            '/serverWxAPI': {
                target: 'https://zzjtpp.top/serverWxAPI', // 目标服务
                changeOrigin: true,
                rewrite: (path:any) => path.replace(/^\/serverWxAPI/, ''),
            },
            '/ChatGPT': {
                // target: 'http://127.0.0.1:8028/blogAPI',
                target: 'https://zzjtpp.top/ChatGPT',
                changeOrigin: true,
                rewrite: (path:any) => path.replace(/^\/ChatGPT/, '')
            }

        }
    },
    // 内联 postcss 注册 tailwindcss
    css: {
        postcss: {
            plugins: postcssPlugins
        }
    }
});
